<!DOCTYPE html>
<html lang="en">
<head> <meta charset=utf-8> </head>

<body>
    <script>
    let count = 0
    let limit = 30 * 1000
    let start = new Date()
    ws = new WebSocket('ws://localhost:4100/ws/', ['chat'])

    ws.onopen = function (event) {
        console.log(`Test started, please wait ...`)
        ws.send("Start test")
    };
    ws.onmessage = function (event) {
        count++
        // console.log(`Got message ${count}`)
        if (count < limit) {
            ws.send(`Test message ${count}`)
        } else {
            let elapsed = new Date() - start
            console.log(`Test complete. ${elapsed / 1000} sec`)
            console.log(`Test complete. ${(count / elapsed * 1000).toFixed(2)} message pairs per sec`)
            ws.close()
        }
    };
    ws.onclose = function (event) { }
    ws.onerror = function (event) {
        console.log("Error " + event)
    }
    </script>
</body>
</html>
